/*
操作state里面的数据
 */
import {ADD_TODO, DEL_TODO, CHECK_ALL_TODO, DEL_ALL_TODO, GET_ALL_TODOS} from "./mutaaions-types";

export default {
  [ADD_TODO](state, {item}) {
    state.todos.unshift(item)
  },
  [DEL_TODO](state, {index}) {
    state.todos.splice(index, 1)
  },
  [CHECK_ALL_TODO](state, {value}) {
    state.todos.forEach(todo => todo.complete = value)
  },
  [DEL_ALL_TODO](state) {
    state.todos = state.todos.filter(todo => !todo.complete)
  },
  [GET_ALL_TODOS](state, {todos}) {
    state.todos = todos
  }
}
